package org.jeecg.modules.utils;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

@Data
public class BikeResult implements Serializable {
    @ApiModelProperty("是否成功")
    private boolean success;
    @ApiModelProperty("请求结果码")
    private String code;
    @ApiModelProperty("请求消息")
    private String message;
    @ApiModelProperty("返回数据")
    private Object data;
    @ApiModelProperty("数据数量")
    private int count;

    public BikeResult() {
    }

    private BikeResult(boolean success, String code, String message, Object data) {
        this.success = success;
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public BikeResult(boolean success, String code, String message, Object data, int count) {
        this.success = success;
        this.code = code;
        this.message = message;
        this.data = data;
        this.count = count;
    }

    public static BikeResult ok(String code, String message, Object data) {
        return new BikeResult(true, code, message, data);
    }

    public static BikeResult ok(Object data, int count) {
        return new BikeResult(true, ResponseCode.RETCODE_SUCCESS, "调用成功", data, count);
    }

    public static BikeResult ok(Object data) {
        return new BikeResult(true, ResponseCode.RETCODE_SUCCESS, "调用成功", data);
    }

    public static BikeResult error(String code, String message, Object data) {
        return new BikeResult(false, code, message, data);
    }

    public static BikeResult error(String message) {
        return new BikeResult(false, (String)null, message, (Object)null);
    }

    public boolean isSuccess() {
        return this.success;
    }

}
